<?
	  layout("/inc/win_layout.html",{title:sysTitle}){
    ?>
<div class="col-lg-4">
	<div class="panel" style="height: 500px; overflow: auto;">
		<div class="panel-heading">知识分类管理</div>
		
		<div class="panel-body">
			<!-- <div><a href="javascript:qingling();">根目录</a></div> -->
			<div style="margin-top: -10px;margin-left: 10px;">
			<button style="height: 35px;width: 55px;" type="button" class="btn btn-blue btn-xs" onclick="qingling()"><h5>根目录</h5></button></div>
			<ul id="tree" class="ztree" style="width:300px"; overflow:auto;"></ul>
		</div>
	</div>
</div>
<?} ?>
<script>
	//树状结构
	$(function() {
		initTree();
	});

	function initTree() {
		$.ajax({
			type : "post",
			data : {

			},
			url : "./domainCategoryZTree.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : drawTree,
		});
	}

	function drawTree(data) {
		var setting = {
			view : {
				dblClickExpand : false,
			},
			data : {
				simpleData : {
					enable : true,
				}
			},
			check : {
				enable : false,
			},
			callback : {
				onClick : onClick
			},
		};
		var zNodes = eval(data);
		$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
		zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.expandNode(zTree.getNodes()[0], true);//指定某节点折叠
	}

	var saveid;
	var savename;
	function onClick(e, treeId, treeNode) {
		saveid = treeNode.id; //获取点击  树形 ID
		savename = treeNode.name; //获取点击 树形 name
	}
	
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	function qingling(){
		parent.$("#id").val("0");
		parent.$("#domainName").val("根节点");
		parent.layer.tips("Ok", "#xuanze", {
				time : 5000
			});
		parent.layer.close(index);
	}
	function queren() {
		if (saveid == null) {
			parent.$("#id").val("0");
			parent.$("#domainName").val("根节点");
			parent.layer.close(index);
		} else {
			parent.$("#domainName").val(savename);
			parent.$("#domainId").val(saveid);
			parent.layer.tips("Ok", "#xuanze", {
				time : 5000
			});
			parent.layer.close(index);
		}
	}
</script>